import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../components/searchbar/index.dart';

class Home extends StatelessWidget {
  const Home({super.key});
  //遍历系统组件
  List<Widget> _sysData() {
    List<ListTile> list = [];
    List<Map<String, dynamic>> fucList = [
      {'icon': Icons.people, 'title': '新的朋友'},
      {'icon': Icons.chat, 'title': '仅聊天的朋友'},
      {'icon': Icons.group, 'title': '群聊'},
      {'icon': Icons.label, 'title': '标签'}
    ];

    for (var i = 0; i < fucList.length; i++) {
      list.add(
        ListTile(
          leading: Icon(fucList[i]['icon'] as IconData), // 明确类型转换
          title: Text(fucList[i]['title'] as String), // 明确类型转换
          onTap: () {
            print("$i");
          },
        ),
      );
    }

    return list;
  }

  void toSearch() {
    Get.toNamed('/search');
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(children: [
        GestureDetector(
          child: const MySearch(),
          onTap: () {
            toSearch();
          },
        ),
        ..._sysData()
      ]),
    );
  }
}
